package com.dgut.hisystem.mapper;

import com.dgut.hisystem.entity.Charge;
import com.dgut.hisystem.entity.VO.ChargeVO;
import com.dgut.hisystem.entity.VO.DailyVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.List;

@Mapper
public interface ChargeMapper {
    @Insert({"INSERT INTO charge_info (bl_id, br_card, sf_charge, sf_refund, sf_cost, sf_datetime) VALUES (#{bl_id},#{br_card},#{sf_charge},#{sf_refund},#{sf_cost},#{sf_datetime})"})
    void insert(Charge charge);
    @Update({"UPDATE charge_info set sf_charge=1 where sf_id=#{sf_id}"})
    void updateCharge(int sf_id);
    @Update({"UPDATE charge_info set sf_refund=1,sf_charge=0 where sf_id=#{sf_id}"})
    void updateRefund(int sf_id);
    @Select({"Select * from charge_info where sf_id = #{sf_id}"})
    Charge getChargeById(int sf_id);
    @Select({"Select * from charge_info where sf_charge = 0 and sf_refund = 0"})
    List<Charge> selectCharge();
    @Select({"Select * from charge_info where sf_charge = 1 and sf_refund = 0"})
    List<Charge> selectRefund();
    @Select({"Select * from charge_info where (sf_charge = 1 or sf_refund = 1) and sf_datetime between #{c} and #{d}"})
    List<Charge> selectDaily(Timestamp c, Timestamp d);
    @Select({"Select * from charge_info where sf_charge = 0 and sf_refund = 0 and br_card like concat('%',#{br_card},'%')"})
    List<Charge> selectChargeByCard(long br_card);
    @Select({"Select * from charge_info where sf_charge = 1 and sf_refund = 0 and br_card like concat('%',#{br_card},'%')"})
    List<Charge> selectRefundByCard(long br_card);
    @Select({"Select * from charge_info where (sf_charge = 1 or sf_refund = 1) and br_card like concat('%',#{br_card},'%') and sf_datetime between #{c} and #{d}"})
    List<Charge> selectDailyByCard(long br_card,Timestamp c, Timestamp d);
}
